//
//  UIDevice+Trackit.m
//  Trackit
//
//  Created by yaodaobin on 2017/4/2.
//  Copyright © 2017年 yaodaobin. All rights reserved.
//

#import "UIDevice+Trackit.h"

@implementation UIDevice (Trackit)

+ (BOOL)is_iPad_Series {
    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
}

+ (BOOL)is_iPhone_Series {
    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone);
}

+ (CGSize)currentModeSize {
    if ([UIScreen instancesRespondToSelector:@selector(currentMode)]) {
        return [[UIScreen mainScreen] currentMode].size;
    } else {
        return CGSizeZero;
    }
}

+ (Device_Screen_Type)getDeviceScreenType {
    if ([self is_iPad_Series]) {
        return iPad;
    } else {
        CGSize size = [self currentModeSize];
        if (CGSizeEqualToSize(size, CGSizeMake(1242,2208))) {
            return iPhone_Screen_5_5;
        } else if (CGSizeEqualToSize(size, CGSizeMake(750,1334))) {
            return iPhone_Screen_4_7;
        } else if (CGSizeEqualToSize(size, CGSizeMake(640, 1136))) {
            return iPhone_Screen_4;
        } else {
            return iPhone_Screen_3_5;
        }
    }
}

/**
 *  device is retina Screen
 *
 *  @return YES: current device is retina screen
 */
+ (BOOL)is_Retina {
    return [[UIScreen mainScreen] scale] >= 2;
}

+ (float)iOSVersion{
    return [[[UIDevice currentDevice] systemVersion] floatValue];
}

@end
